// *************************************************************************************************
//
// MK3D Engine
// --------------------------------------
// Copyright (C) 2007-2011 Zeb (mailto: zebbey@gmail.com)
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// *************************************************************************************************

#ifndef __H_MK_DI8_KEYBOARD__
#define __H_MK_DI8_KEYBOARD__

#include "mk_input.h"

namespace MK3DE
{
	class CDeviceKeyboard :
		public CInputDevice
	{
	public:
		CDeviceKeyboard(void);
		~CDeviceKeyboard(void);

	public:
		HRESULT UpdateImmediateData(BYTE state[], DWORD size);
		HRESULT UpdateBufferedData();

		HRESULT ClearBuffer();

		HRESULT GetKeyState(BYTE keyState[], DWORD key, KEY_STATE& state);    

		HRESULT GetInputEvent(InputEvent& event);

	public:
		HRESULT Create(LPDIRECTINPUT8 pDirectInput, HWND hWnd, COOPERATIVE_LEVEL cl, DWORD size);

	private:
		LPDIRECTINPUTDEVICE8 _keyboard;
		BOOL _isDeviceLost;
		DWORD _bufferSize;
		DIDEVICEOBJECTDATA* _eventBuffer;
		DWORD _eventCount;
		DWORD _currentEvent;
	};
};

#endif // __H_MK_DI8_KEYBOARD__